/*
 * @Description:
 * @Version: 1.0
 * @Autor: laikt
 * @Date: 2020-12-30 10:43:50
 * @LastEditors: laikt
 * @LastEditTime: 2021-01-12 10:55:59
 */
import { cloneDeep } from 'lodash'

const env = cloneDeep(process.env)

let newEnv = {}

Object.keys(env).forEach(keyname => {
    if (/^.+\|(number|string)$/.test(env[keyname])) {
        const [value, type] = env[keyname].split('|')
        switch (type) {
            case 'number':
                newEnv[keyname] = Number(value)
                break
            case 'string':
                if (value === 'empty') {
                    newEnv[keyname] = ''
                } else {
                    newEnv[keyname] = String(value)
                }
                break
            default:
                break
        }
    } else {
        newEnv[keyname] = env[keyname]
    }
})
console.log(newEnv)
export default newEnv
